#include "TabelMhs.h"

int main() {
	TabelMhs T = CreateEmptyTabelMhs();
	PrintTabelMhs(T); puts("-");
	AddRecordMhs(AllocateRecordMhs(CharToString("13508004"), CharToString("Ecky"), MakeTanggal(12,04,1990), CharToString("Jakarta")), &T);
	PrintTabelMhs(T); puts("-");
	AddRecordMhs(AllocateRecordMhs(CharToString("13508020"), CharToString("Ghufron"), MakeTanggal(19,05,1991), CharToString("Demak")), &T);
	AddRecordMhs(AllocateRecordMhs(CharToString("19906001"), CharToString("Amin Badrun"), MakeTanggal(01,8,1990), CharToString("Bandung")), &T);
	AddRecordMhs(AllocateRecordMhs(CharToString("19906003"), CharToString("Emi Fitria"), MakeTanggal(23,06,1990), CharToString("Surabaya")), &T);
	PrintTabelMhs(T); puts("-");
	
	do {
		printf("Query : "); ReadArguments(NULL);
		AddressMhs A;
		bool query = true;
		TRAVERSETOEND2(A,FIRST(T)) {
			if(!query) break;
			if(EvaluateQueryTabelMhs(A,CReader,&query)) { PrintRecordMhs(A, true, true, true, true, true, true); printf("\n"); }
		}
		if(!query) puts("Query gagal!");
	} while(CReader.nArgument!=0);
	
	DestroyRecordMhs(SearchRecordMhsByNIM(CharToString("19906001"), &T), &T);
	if(SearchRecordMhsByNIM(CharToString("13508004"), &T)!=NULL) puts("13508004 ADA!"); else puts("13508004 GA ADA!");
	PrintTabelMhs(T); puts("-");
	printf("\n");
	printf("Menghapus isi tabel T\n");
	DestroyTabelMhs(&T);
	PrintTabelMhs(T); puts("-");

	return 0;
}
